home *** CD-ROM | disk | FTP | other *** search
- /*
- ** MAILER.C [edit EMAIL.H before compiling]
- **
- ** This program emails a specified message.
- */
-
- #include <windows.h>
- #include <stdio.h>
- #include "see.h"
- #include "email.h"
-
- #define QUOTE 0x22
-
- static char Buffer[512];
-
- /* display error message */
-
- static void ErrorExit(int Code, LPSTR Msg)
- {printf("ERROR: ");
- if(Msg) printf("%s\n",Msg);
- if(Code)
- {seeErrorText(Code,(LPSTR)Buffer,50);
- printf("%s\n",(LPSTR)Buffer);
- exit(1);
- }
- }
-
- void main(int argc, char *argv[])
- {int Code;
- if(argc!=4)
- {printf("Usage: MAILER email-text subject <email-addr>\n");
- printf(" eg: MAILER %c@test.mai%c %cThis is a test%c %c<mike@marshallsoft.com>%c\n",
- QUOTE,QUOTE,QUOTE,QUOTE,QUOTE,QUOTE);
- exit(1);
- }
-
- /* display parameters */
- printf("Server : %s\n",(LPSTR)SMTP_HOST_NAME);
- printf(" From : %s\n",(LPSTR)YOUR_EMAIL_ADDR);
- if(*argv[1]=='@') printf(" File : %s\n", argv[1]);
- else printf(" Text : %c%s%c\n", QUOTE,argv[1],QUOTE);
- printf(" Subj : %s\n", argv[2]);
- printf(" To : %s\n", argv[3]);
-
- /* check format of email addresses */
- Code = seeVerifyFormat((LPSTR)argv[3]);
- if(Code<0) ErrorExit(Code,(LPSTR)argv[3]);
- Code = seeVerifyFormat(YOUR_EMAIL_ADDR);
- if(Code<0) ErrorExit(Code,(LPSTR)YOUR_EMAIL_ADDR);
-
- /* define diagnostics log file */
- seeStringParam(SEE_LOG_FILE, (LPSTR)"mailer.log");
-
- /* connect to SMTP server */
- puts("Connecting...");
- Code = seeSmtpConnect(
- (LPSTR)SMTP_HOST_NAME, /* SMTP server */
- (LPSTR)YOUR_EMAIL_ADDR, /* return email address */
- (LPSTR)NULL); /* Reply-To header */
- if(Code<0)ErrorExit(Code,(LPSTR)"Connect:");
- /* send email */
- puts("Sending mail...");
- Code = seeSendEmail(
- (LPSTR)argv[3], /* To list */
- (LPSTR)NULL, /* CC list */
- (LPSTR)NULL, /* BCC list */
- (LPSTR)argv[2], /* subject */
- (LPSTR)argv[1], /* message text */
- (LPSTR)NULL); /* MIME attachment */
- if(Code<0) ErrorExit(Code,(LPSTR)"Sending email:");
- Code = seeClose();
- } /* end main */
-
-
-